package com.twu.biblioteca.domain;

public class Movie {

    public static final int NOT_RATED = 0;

    private String title;
    private int year;
    private String director;
    private int rating;

    public Movie(String title, int year, String director, int rating) {

        this.title = title;
        this.year = year;
        this.director = director;
        this.rating = rating;
    }

    @Override
    public String toString(){
        return String.format("%s | %d | %s | %s", title, year, director, getRatingAsText());
    }

    private String getRatingAsText(){
        if (!this.hasRating())
            return "N/A";

        return String.valueOf(rating);
    }

    private boolean hasRating() {
        return this.rating != NOT_RATED;
    }
}
